implement pod exec websockets v5#2486
Conversation
|
Welcome @aojea! |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
|
/remove-lifecycle rotten |
|
/assign |
|
/lifecycle frozen |
|
@seans3: The DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
seans3
left a comment
There was a problem hiding this comment.
This looks good and substantially complete.
One high-level observation: I believe falling back to v4.channel.k8s.io is the right approach for backwards compatibility, but we should probably note that for clusters < v1.30, the client will silently revert to the broken behavior and hang on EOF.
I've left a few minor inline comments mostly about tests and constants.
| del self._channels[channel] | ||
| return ret | ||
|
|
||
| if channel in self._closed_channels: |
There was a problem hiding this comment.
Do we need this same short-circuiting code in peek_channel and read_channel ?
| """Close a channel (v5 protocol only).""" | ||
| if self.subprotocol != V5_CHANNEL_PROTOCOL: | ||
| return | ||
| data = bytes([255, channel]) |
There was a problem hiding this comment.
Should we define a constant (e.g. CLOSE_CHANNEL = 255 or V5_HALF_CLOSE = 255) for this magic number, and reference the constant?
|
|
||
| mock_ws.send.assert_not_called() | ||
|
|
||
| def test_update_receives_close_v5(self): |
There was a problem hiding this comment.
Should we add an additional unit test to verify how readline_channel handles a closed channel with leftover data?
While the current unit tests cover the parsing of the close signal itself, the new logic you added inside readline_channel—which flushes the remaining buffer even if it lacks a newline—is currently untested. Having a test that asserts readline_channel successfully flushes leftover data (e.g. "hello") and then returns an empty string on the subsequent call would ensure this specific edge-case logic is protected from future regressions.
There was a problem hiding this comment.
added tests also for read_channel and peek_channel to validate channels are drained and follow the expected semantics
|
/assign @yliaog |
| # In Py3, iterating bytes gives int, but indexing bytes gives int. | ||
| # websocket-client frame.data might be bytes. | ||
|
|
||
| if channel == 255 and self.subprotocol == V5_CHANNEL_PROTOCOL: # v5 CLOSE |
There was a problem hiding this comment.
better to replace 255 with a constant
implementation is able to signal a channel is closed to the other side. Clients are also able to drain the closed channels.
|
Looks great--thanks. /lgtm |
|
@seans3: changing LGTM is restricted to collaborators DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
| if resp.subprotocol != "v5.channel.k8s.io": | ||
| resp.close() | ||
| api.delete_namespaced_pod(name=name, body={}, namespace='default') | ||
| self.skipTest("Skipping test: v5.channel.k8s.io subprotocol not negotiated") |
There was a problem hiding this comment.
the test is skipped in the e2e test flow: https://github.com/kubernetes-client/python/actions/runs/25740181177/job/75636044165
how to make it run?
There was a problem hiding this comment.
kubernetes/e2e_test/test_client.py::TestClient::test_pod_exec_close_channel SKIPPED
There was a problem hiding this comment.
we need to get a more recent version of kind, let me update that
There was a problem hiding this comment.
it was not the version, the e2e tests were not initializing the subprotocol so it never matched ... now the client if is not preconfigured, uses the subprotocol obtained during the negotiation
|
@yliaog is it normal for the e2e tests to take so long? they take more than 3 hours, that sounds like a lot |
|
the e2e takes a long time in the informer tests, i have not had a chance to look into why it takes so long. |
Fixed im the latest commit, there was deadlockimg when.closing, added a comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, yliaog The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature
/kind api-change
/kind deprecation
cc: @yliaog @siyuanfoundation